<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		*{
			margin:0;
			padding: 0;
		}
		body{
			background: #ccc;
			/*opacity: 0.5;*/
		}
		#wrap{
			width: 300px;
			height: 200px;
			background: black;
			margin:150px auto;
		}
		#wrap p{
			color: white;
			line-height: 80px;
			margin-left: 30px;
		}
		button{
			margin-left: 70px;
		}
	</style>
</head>
<body>
	<div id="wrap">
		<p>用户名:<input type="text" name="" id="txt"></p>
		<p>密&nbsp;码:<input type="password" name="" id="pass"></p>
		<button id="btn1">注册</button><button id="btn2">登陆</button>
	</div>
</body>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
//注册
$("#btn1").on("click",function(){
	// if($("#txt").val() == ""||$("#pass").val() == ""){
	// 	alert("注册为空")
	// }else{
		var a1={
			username:$("#txt").val(),
			password:$("#pass").val()
		}

		$.ajax({
		url:"http://localhost:2403/users",
		type:"post",
		data:a1,
		success:function(data){
			console.log(data);
			alert("注册成功");
		}
	})
	// }	
})

//登陆
$("#btn2").on("click",function(){
	var a2 = {
		username:$("#txt").val(),
		password:$("#pass").val()
	}
	$.ajax({
		url:"http://localhost:2403/users/login",
		type:"post",
		data:a2,
		success:function(data){
			console.log(data);
			window.open("图书管理系统.html");
		}
	})

})
</script>
</html>